<template>
  <div class="articles">
    <div class="section-title">
      <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M12 2L14.5 8H21L16 12L18 18L12 15L6 18L8 12L3 8H9.5L12 2Z" fill="#64B5F6"/>
      </svg>
      <h3>最新文章</h3>
    </div>
    <div class="article-card" v-for="article in articles" :key="article.id">
      <div class="article-header">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
          <path d="M12 2L14.5 8H21L16 12L18 18L12 15L6 18L8 12L3 8H9.5L12 2Z" fill="#90CAF9"/>
        </svg>
        <h4>{{ article.title }}</h4>
      </div>
      <p>{{ article.excerpt }}</p>
      <div class="meta">
        <span>🌸 发布时间：{{ article.createdAt }}</span>
        <router-link :to="`/articles/${article.id}`" class="read-more">阅读全文 →</router-link>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';
// 模拟数据（实际需从后端接口获取）
const articles = ref([
  {
    id: 1,
    title: "Vue3 组件通信最佳实践",
    excerpt: "介绍 props、emit、provide/inject 等通信方式，让组件交互更顺畅...",
    createdAt: "2025-05-16"
  },
  {
    id: 2,
    title: "前端性能优化指南",
    excerpt: "从加载速度、渲染优化到缓存策略，全面提升应用体验...",
    createdAt: "2025-05-10"
  }
])
</script>

<style scoped>
.articles {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  background-color: #FFF0F3;
  border-radius: 15px;
  margin-top: -50px;
  position: relative;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(255, 183, 197, 0.2);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 2rem;
  color: #1976D2;
}

.section-title h3 {
  font-family: 'Comic Sans MS', cursive, sans-serif;
  font-size: 1.8rem;
  margin: 0;
}

.article-card {
  background: linear-gradient(135deg, white 0%, #E3F2FD 100%);
  border-radius: 15px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 5px 15px rgba(100, 181, 246, 0.2);
  transition: all 0.3s ease;
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(33, 150, 243, 0.3);
}

.article-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.article-header h4 {
  font-family: 'Comic Sans MS', cursive, sans-serif;
  font-size: 1.3rem;
  color: #1976D2;
  margin: 0;
}

.article-card p {
  color: #5D4037;
  line-height: 1.6;
  font-family: 'Comic Sans MS', cursive, sans-serif;
}

.meta {
  margin-top: 1.5rem;
  color: #8D6E63;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Comic Sans MS', cursive, sans-serif;
}

.read-more {
  color: #2196F3;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.read-more:hover {
  color: #1565C0;
  transform: translateX(3px);
}
</style>